#include <stdio.h>

namespace HSL
{

#define MIN_TO_RAD 2.9088820866572159615394846141477e-4
#define RAD_TO_MIN 3437.7467707849392526078892888463
static bool ComputeSin()
{
	FILE *pFile = fopen("crSinCos.h", "wt");
	fprintf(pFile, "static float s_pfSin[] = {\n");
	for(int i = 0; i < 90; i++)
	{
		fprintf(pFile, "\t");
		for(int j = 0; j < 60; j++)
		{
			float v = (float)sin(MIN_TO_RAD * (i*60 + j));
			fprintf(pFile, "%.8ff, ", v);
		}
		fprintf(pFile, "\n");
	}
	fprintf(pFile, "\t1.00000000f\n};\n");
	

	fprintf(pFile, "static __int16 s_pnSin[] = {\n");
	for(int i = 0; i < 90; i++)
	{
		fprintf(pFile, "\t");
		for(int j = 0; j < 60; j++)
		{
			int v = Float2IntRound( (float)(4096*sin(MIN_TO_RAD * (i*60 + j))) );
			fprintf(pFile, "%4d, ", v);
		}
		fprintf(pFile, "\n");
	}
	fprintf(pFile, "\t4096\n};\n");

	fprintf(pFile, "static __int16 s_pnAsin[] = {\n");
	for(int i = 0; i < 64; i++)
	{
		fprintf(pFile, "\t");
		for(int j = 0; j < 64; j++)
		{
			int v = Float2IntRound((float)(RAD_TO_MIN*asin((i*64 + j)/4096.0)));
			fprintf(pFile, "%4d, ", v);
		}
		fprintf(pFile, "\n");
	}
	fprintf(pFile, "\t5400\n};\n");

	fclose(pFile);

	return true;
}

bool bOk = ComputeSin();